home *** CD-ROM | disk | FTP | other *** search
- ' Local definitions to remember grid drag mode
-
- Dim InitialX As Single
- Dim InitialY As Single
-
- Const DRAG_DELTA = 30 ' determines when drag starts
-
- ' Type masks
-
- Global Const MASK_NONE = 0
- Global Const MASK_CUST = 1
- Global Const MASK_OBROWSE = 2
- Global Const MASK_PARTS = 4
- Global Const MASK_ORDER = 8
- Global Const MASK_TABLE = 16
-
- ' Drag mode constants to keep track of dragging activity.
-
- Global DragType As Integer ' type of object being dragged
- Dim Dragging As Integer ' TRUE when dragging is in progress
- Dim DragIndex As Integer ' Optional index of dragged obj
- Dim DragRow As Integer ' Optional row being dragged in grid
- Dim DragTesting As Integer ' TRUE when test drag in progress
-
- ' ----------------------------------
- ' Microsoft Windows API declarations
- ' ----------------------------------
-
- ' Type definitions used for grid interfacing
-
- Type POINTAPI
- X As Integer
- Y As Integer
- End Type
-
- Type RECT
- Left As Integer
- Top As Integer
- Right As Integer
- Bottom As Integer
- End Type
-
- ' TrueGrid message code for returning bounding box of the marquee
-
- Const WM_USER = &H400
- Const GRM_GETCELLRECT = WM_USER + 62
-
- ' Windows API declarations
-
- Declare Function SendMessage Lib "User" (ByVal Hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, lParam As Any) As Long
- Declare Sub ClientToScreen Lib "User" (ByVal Hwnd As Integer, lpPoint As POINTAPI)
- Declare Sub GetCursorPos Lib "User" (lpPoint As POINTAPI)
-
- Sub BeginDragMode (ctl As Control, objType As Integer)
-
- ' Whenever a drag is about to start, this routine is called.
- ' The type mask of the drag is flagged, and we remember that
- ' dragging is in progress. This routine MUST be matched
- ' by an EndDragMode function call.
-
- DragType = objType
- Dragging = True
-
- ' Start the drag process
-
- ctl.Drag BEGIN_DRAG
-
- End Sub
-
- Function CursorInRow (DragGrid As Control) As Integer
-
- ' Return a boolean indicating whether the cursor is within the marquee
-
- Dim Marquee As RECT
- Dim CursorPos As POINTAPI
-
- ' Eliminate the situation where the current cell is not within the visible
- ' area of the grid.
-
- CursorInRow = False
-
- If DragGrid.RowIndex < DragGrid.TopRow Then Exit Function
- If DragGrid.RowIndex > DragGrid.BottomRow Then Exit Function
-
- GetMarquee DragGrid, Marquee
- GetCursorPos CursorPos
-
- If CursorPos.Y >= Marquee.Top And CursorPos.Y <= Marquee.Bottom Then
- CursorInRow = True
- End If
-
- End Function
-
-
- Function DragValid (src As Control, mask As Integer, State As Integer) As Integer
-
- ' This function is called by an object's DragOver event to
- ' automatically change the drag cursor to the "no drop"
- ' cursor if necessary. It also returns True if the object
- ' can legally be dropped according to the input mask.
-
- If (mask And DragType) Then
- DragValid = True
- Exit Function
- End If
-
- ' This is not a valid drag. Return False, but also change the
- ' object's drag icon to the NoDrag icon (remembering the old
- ' value for later restore when we exit this object).
-
- DragValid = False
-
- Select Case State
-
- Case ENTER
-
- ' Entering, remember old icon
-
- Utils.SaveIcon.DragIcon = src.DragIcon
- src.DragIcon = Utils.NoDrag.DragIcon
-
- Case LEAVE
-
- ' Exiting, restore old icon
-
- src.DragIcon = Utils.SaveIcon.DragIcon
-
- End Select
-
- End Function
-
- Function EndDragMode (mask As Integer) As Integer
-
- ' This function is called when a drag has ended, either
- ' successfully or unsuccessfully. This routine removes any
- ' user feedback related to the drag operation and returns
- ' TRUE if the passed mask matches the dragged object.
-
- Select Case DragType
-
- Case MASK_NEWAPPT
-
- ' If a "new appointment" icon was dragged, change the
- ' frame background to LTGREY again so that the drag
- ' is officially over.
-
- 'KindFrame(DragIndex).BackColor = LTGREY
-
- Case MASK_OLDAPPT
-
- ' If this is an item dragged from the grid, refresh
- ' the grid in case the drag ended outside the grid
- ' frame (and the inverted row remains).
-
- 'ApptList.Refresh
-
- End Select
-
- Dragging = False
- DragTesting = False
- EndDragMode = (mask And DragType) <> 0
-
- End Function
-
- Sub GetMarquee (DragGrid As Control, Marquee As RECT)
-
- ' Return the bounding box of the marquee, in screen coordinates
-
- Dim GridOrigin As POINTAPI
- Dim GridCorner As POINTAPI
-
- N& = SendMessage(DragGrid.Hwnd, GRM_GETCELLRECT, 0, Marquee)
-
- GridOrigin.X = Marquee.Left
- GridOrigin.Y = Marquee.Top
- GridCorner.X = Marquee.Right
- GridCorner.Y = Marquee.Bottom
-
- ClientToScreen DragGrid.Hwnd, GridOrigin
- ClientToScreen DragGrid.Hwnd, GridCorner
-
- Marquee.Left = GridOrigin.X
- Marquee.Top = GridOrigin.Y
- Marquee.Right = GridCorner.X
- Marquee.Bottom = GridCorner.Y
- End Sub
-
- Sub GridMaybeDrag (ctl As Control, X As Single, Y As Single)
-
- ' Called by MouseDown handlers to see whether or not
- ' dragging is a *possibility* after some motion.
-
- If Not CursorInRow(ctl) Then Exit Sub
- InitialX = X
- InitialY = Y
- DragTesting = True
- End Sub
-
- Sub GridTestDrag (ctl As Control, Button As Integer, X As Single, Y As Single, objType As Integer, dicon As Control)
-
- ' Called during MouseMove by controls desiring drag
- ' and drop behavior.
-
- If Button = 0 Then
- DragTesting = False
- Exit Sub
- End If
- If Not DragTesting Then Exit Sub
- If Abs(InitialX - X) > DRAG_DELTA Or Abs(InitialY - Y) > DRAG_DELTA Then
- ctl.DragIcon = dicon.DragIcon
- BeginDragMode ctl, objType
- End If
- End Sub
-
-